package test;

import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * @author oldliu
 * @since 1.0
 */
public class FileWriterLiaotian {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        FileOutputStream fos = new FileOutputStream("D:\\abc.txt", true);
        while (true) {
            System.out.println("输入字符串");
            String s = sc.nextLine();
            if (s.equals("quit")) {
                break;
            } else {
                Date d = new Date();
                SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss");
                String format = sdf.format(d);
                byte[] bytes2 = format.getBytes();
                fos.write(bytes2);//输入时间
                fos.write(32);//输入空格
                byte[] bytes = s.getBytes();
                fos.write(bytes);
                byte[] bytes1 = "\r\n".getBytes();
                fos.write(bytes1);
            }
        }
        fos.close();
    }
}
